********************************************************************************
* Bloom, Canning, Kotschy, Prettner, Schünemann
* Health and Economic Growth: Reconciling Micro and Macro-Evidence
* Replication File
********************************************************************************

version 17
clear all
set more off
capture log close
program drop _all
mata: mata set matafavor speed, perm
cd

* Install necessary software packages (see README file)
ssc install ranktest, replace
ssc install ftools, replace
ssc install moremata, replace
ssc install ivreg2, replace
ssc install xtabond2, replace
ssc install estout, replace

********************************************************************************
* Table 1: Estimated Macroeconomic Return to Health

use "bckps_data.dta", clear
mi xtset id year, delta(5)
* Column 1: Baseline controls
qui eststo table1c1: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, cl(id)
* Column 2: Baseline controls and working experience
qui eststo table1c2: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.exp D.expsq D.wfpopratio instquality td1970-td2015, cl(id)
* Column 3: Baseline controls and income inequality
qui eststo table1c3: mi est, post: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.gini D.wfpopratio instquality td1970-td2015, cl(id)
* Column 4: Baseline controls and lagged controls
qui eststo table1c4: reg D.lgdppc L.lgdppc D.lkpw L.lkpw D.asr1560 L.asr1560 D.syos1564 L.syos1564 D.wfpopratio L.wfpopratio instquality td1970-td2015, cl(id)
* Column 5: Baseline controls and country-specific growth trends
mi extract 0
qui eststo table1c5: xtreg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, fe cl(id)
* Column 6: Panel GMM
qui eststo table1c6: xtabond2 D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, ///
	gmm(L.lgdppc lkpw asr1560 syos1564 L.syos1564, l(1 1)) iv(D.wfpopratio instquality td1970-td2015) cl(id) two
mat m = e(diffsargan)
loc diffhp: di %5.2f m[5,1]
estadd sca diffhp = `diffhp': table1c6
estadd sca N_clust = e(N_g): table1c6
* Display results
esttab table1*, b(%8.3f) se(%8.3f) star(* .1 ** .05 *** .01) k(L.lgdppc D.lkpw D.asr1560 D.syos1564 D.wfpopratio) sca(N_clust N r2 ar2p hansenp diffhp) sfmt(a2) dep noobs nonotes compress

* Footnote 7
use "bckps_data.dta", clear
mi xtset id year, delta(5)
mi extract 0
reg D.lgdppc L.lgdppc DL.lkpw DL.asr1560 DL.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, cl(id)
* Footnote 8
use "bckps_data.dta", clear
mi xtset id year, delta(5)
mi extract 0
g y = lgdppc - wfpopratio
xtreg D.y L.y D.lkpw D.asr1560 D.syos1564 L.syos1564 instquality td1970-td2015, fe cl(id)

********************************************************************************
* Table 2: Stability across Samples and over Time

use "bckps_data.dta", clear
mi xtset id year, delta(5)
* Column 1: Full sample
qui eststo table2c1: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, cl(id)
* Column 2: Balanced sample
qui eststo table2c2: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015 if sample_blcd == 1, cl(id)
* Column 3: Excluding advanced economies
qui eststo table2c3: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015 if sample_noadvecon == 1, cl(id)
* Column 4: Excluding socialist countries
qui eststo table2c4: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015 if sample_nosocialist == 1, cl(id)
* Column 5: Sample 1965-2005
qui eststo table2c5: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015 if year >= 1965 & year <= 2005, cl(id)
* Column 6: Sample 1975-2015
qui eststo table2c6: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015 if year >= 1975 & year <= 2015, cl(id)
* Display results
esttab table2*, b(%8.3f) se(%8.3f) star(* .1 ** .05 *** .01) k(L.lgdppc D.lkpw D.asr1560 D.syos1564 D.wfpopratio) sca(N_clust N r2) sfmt(a2) dep noobs nonotes compress

* Footnote 9
use "bckps_data.dta", clear
mi xtset id year, delta(5)
reg D.lgdppc L.lgdppc D.lkpw D.asr1560 humi cD.asr1560#humi D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, cl(id)
mi extract 0, clear
xtreg D.lgdppc L.lgdppc D.lkpw D.asr1560 cD.asr1560#humi D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, fe cl(id)

********************************************************************************
* Table 3: Comparison of Our Estimates with Evidence in the Literature

use "bckps_data.dta", clear
mi xtset id year, delta(5)
qui reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, cl(id)
nlcom (lambda: _b[L.lgdppc]) (alpha: _b[D.lkpw]) (phi_h: 10 * _b[D.asr1560]/(1-_b[D.lkpw])) (phi_s: 100 * _b[D.syos1564]/(1-_b[D.lkpw])), post cformat(%6.2f)

********************************************************************************
* Table A.1: Selected Estimates of the Macroeconomic Return to Health in the Literature

use "bckps_data.dta", clear
mi xtset id year, delta(5)

* Compute conversion factor for life expectancy and adult survival in the sample
qui reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.yos1564 L.yos1564 D.wfpopratio instquality td1970-td2015, cl(id)
reg lexpb asr1560 if e(sample) == 1
sca def x = 1/(_b[asr1560]*0.01)
qui su lexpb if year == 2000 & e(sample) == 1
sca def y = r(mean)
mat tablea1 = J(13,1,.)
mat rownames tablea1 = acemoglu_johnson aghion_etal barro barro_lee bloom_etal bloom_williamson caselli_etal gallup_sachs hansen_loenstrup lorentzen_etal sala_i_martin_etal shastry_weil weil
* Acemoglu and Johnson (2007)
mat tablea1[1,1] = -1.32*x*(1/y)
* Aghion et al. (2011)
mat tablea1[2,1] = 1.73*x*(1/y)
* Barro (2013)
mat tablea1[3,1] = 0.042*x*(1/y)*100
* Barro and Lee (1994)
mat tablea1[4,1] = 0.073*x*(1/y)*100
* Bloom et al. (2004)
mat tablea1[5,1] = 0.040*x
* Bloom and Williamson (1998)
mat tablea1[6,1] = 0.040*x*(1/y)*100
* Caselli et al. (1996)
mat tablea1[7,1] = -0.001*x*(1/y)*100
* Gallup and Sachs (2001)
mat tablea1[8,1] = 0.030*x*(1/y)*100
* Hansen and Loenstrup (2015)
mat tablea1[9,1] = -1.261*x*(1/y)
* Lorentzen et al. (2008)
mat tablea1[10,1] = -6.699/100*(-1)
* Sala-i-Maritn et al. (2004)
mat tablea1[11,1] = 0.081*x
* Shastry and Weil (2003)
mat tablea1[12,1] = 0.0018*10
* Weil (2007)
mat tablea1[13,1] = 0.653/100
* Display results
mat li tablea1, f(%6.3f)

********************************************************************************
* Table A.2: Descriptive Statistics

use "bckps_data.dta", clear
mi xtset id year, delta(5)
replace gini = _1_gini
forvalues x = 2/100	{
	qui replace gini = gini + _`x'_gini
}
qui replace gini = gini / 100

form lgdppc lgdppw lkpw %10.2f
form syos1564 yos1564 %6.2f
form lnpop trade latropics lacl100km ethfrac %6.2f

su lgdppc D.lgdppc lgdppw D.lgdppw lkpw D.lkpw if sample == 1, f
su asr1560 D.asr1560 lexpb D.lexpb syos1564 D.syos1564 yos1564 D.yos1564 if sample == 1, f
su instquality wfpopratio D.wfpopratio exp D.exp gini D.gini D.lnpop trade latropics lacl100km ethfrac if sample == 1, f

********************************************************************************
* Table A.3: List of Countries in Sample

use "bckps_data.dta", clear
preserve
bysort id: egen in_sample = total(sample)
bysort id: egen in_sample_blcd = total(sample_blcd)
bysort id: egen in_sample_noadvecon = total(sample_noadvecon)
bysort id: egen in_sample_nosocialist = total(sample_nosocialist)
replace in_sample = 1 if in_sample > 0 
replace in_sample_blcd = 1 if in_sample_blcd > 0
replace in_sample_noadvecon = 1 if in_sample_noadvecon > 0
replace in_sample_nosocialist = 1 if in_sample_nosocialist > 0
keep if sample == 1
duplicates drop country, force
sort country
li country in_sample in_sample_blcd in_sample_noadvecon in_sample_nosocialist
restore

********************************************************************************
* Table A.4: Estimated Macroeconomic Return to Health: Full Results

use "bckps_data.dta", clear
mi xtset id year, delta(5)
* Column 1: Baseline controls
qui eststo tablea4c1: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, cl(id)
* Column 2: Baseline controls and working experience
qui eststo tablea4c2: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.exp D.expsq D.wfpopratio instquality td1970-td2015, cl(id)
* Column 3: Baseline controls and income inequality
qui eststo tablea4c3: mi est, post: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.gini D.wfpopratio instquality td1970-td2015, cl(id)
* Column 4: Baseline controls and lagged controls
qui eststo tablea4c4: reg D.lgdppc L.lgdppc D.lkpw L.lkpw D.asr1560 L.asr1560 D.syos1564 L.syos1564 D.wfpopratio L.wfpopratio instquality td1970-td2015, cl(id)
* Column 5: Baseline controls and country-specific growth trends
mi extract 0
qui eststo tablea4c5: xtreg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, fe cl(id)
* Column 6: Panel GMM
qui eststo tablea4c6: xtabond2 D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, ///
	gmm(L.lgdppc lkpw asr1560 syos1564 L.syos1564, l(1 1)) iv(D.wfpopratio instquality td1970-td2015) cl(id) two
mat m = e(diffsargan)
loc diffhp: di %5.2f m[5,1]
estadd sca diffhp = `diffhp': tablea4c6
estadd sca N_clust = e(N_g): tablea4c6
* Display results
esttab tablea4*, b(%8.3f) se(%8.3f) star(* .1 ** .05 *** .01) drop(td* _cons) sca(N_clust N r2 ar2p hansenp diffhp) sfmt(a2) dep noobs nonotes compress ///
	order(L.lgdppc D.lkpw D.asr1560 D.syos1564 D.wfpopratio L.syos1564 instquality D.exp D.expsq D.gini L.lkpw L.asr1560 L.wfpopratio)

********************************************************************************
* Table A.5: The Macroeconomic Return to Health across Models

use "bckps_data.dta", clear
mi xtset id year, delta(5)
* Column 1: Baseline controls
qui reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, cl(id)
qui eststo tablea5c1: nlcom (alpha: _b[D.lkpw]) (phi_h: 10 *_b[D.asr1560]/(1-_b[D.lkpw])), post
* Column 2: Baseline controls and working experience
qui reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.exp D.expsq D.wfpopratio instquality td1970-td2015, cl(id)
qui eststo tablea5c2: nlcom (alpha: _b[D.lkpw]) (phi_h: 10 * _b[D.asr1560]/(1-_b[D.lkpw])), post
* Column 3: Baseline controls and income inequality
qui mi est, post: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.gini D.wfpopratio instquality td1970-td2015, cl(id)
qui eststo tablea5c3: nlcom (alpha: _b[D.lkpw]) (phi_h: 10 * _b[D.asr1560]/(1-_b[D.lkpw])), post
* Column 4: Baseline controls and lagged controls
qui reg D.lgdppc L.lgdppc D.lkpw L.lkpw D.asr1560 L.asr1560 D.syos1564 L.syos1564 D.wfpopratio L.wfpopratio instquality td1970-td2015, cl(id)
qui eststo tablea5c4: nlcom (alpha: _b[D.lkpw]) (phi_h: 10 * _b[D.asr1560]/(1-_b[D.lkpw])), post
* Column 5: Baseline controls and country-specific growth trends
mi extract 0
qui xtreg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, fe cl(id)
qui eststo tablea5c5: nlcom (alpha: _b[D.lkpw]) (phi_h: 10 * _b[D.asr1560]/(1-_b[D.lkpw])), post
* Column 6: Panel GMM
qui xtabond2 D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, ///
	gmm(L.lgdppc lkpw asr1560 syos1564 L.syos1564, l(1 1)) iv(D.wfpopratio instquality td1970-td2015) cl(id) two
qui eststo tablea5c6: nlcom (alpha: _b[D.lkpw]) (phi_h: 10 * _b[D.asr1560]/(1-_b[D.lkpw])), post
* Display results
esttab tablea5c*, b(%8.1f) k(phi_h) nostar nonotes not noobs compress

********************************************************************************
* Table A.6: Robustness: Additional Control Variables

use "bckps_data.dta", clear
mi xtset id year, delta(5)
* Column 1: Baseline specification
qui eststo tablea6c1: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, cl(id)
* Column 2: Controlling for population size
qui eststo tablea6c2: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality lnpop td1970-td2015, cl(id)
* Column 3: Controlling for population growth
qui eststo tablea6c3: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality D.lnpop td1970-td2015, cl(id)
* Column 4: Controlling for trade openness
qui eststo tablea6c4: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality trade td1970-td2015, cl(id)
* Column 5: Controlling for tropical land area
qui eststo tablea6c5: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality latropics td1970-td2015, cl(id)
* Column 6: Controlling for land area within 100 km of ice-free coast
qui eststo tablea6c6: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality lacl100km td1970-td2015, cl(id)
* Column 7: Controlling for ethnic fractionalization
qui eststo tablea6c7: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality ethfrac td1970-td2015, cl(id)
* Display results
esttab tablea6*, b(%8.3f) se(%8.3f) star(* .1 ** .05 *** .01) sca(N_clust N r2) sfmt(a2) dep noobs nonotes compress ///
	k(L.lgdppc D.lkpw D.asr1560 D.syos1564 D.wfpopratio lnpop D.lnpop trade latropics lacl100km ethfrac) 

********************************************************************************
* Table A.7: Robustness: Income per Worker

use "bckps_data.dta", clear
mi xtset id year, delta(5)
* Column 1: Baseline controls
qui eststo tablea7c1: reg D.lgdppw L.lgdppw D.lkpw D.asr1560 D.syos1564 L.syos1564 instquality td1970-td2015, cl(id)
* Column 2: Baseline controls and working experience
qui eststo tablea7c2: reg D.lgdppw L.lgdppw D.lkpw D.asr1560 D.syos1564 L.syos1564 D.exp D.expsq instquality td1970-td2015, cl(id)
* Column 3: Baseline controls and income inequality
qui eststo tablea7c3: mi est, post: reg D.lgdppw L.lgdppw D.lkpw D.asr1560 D.syos1564 L.syos1564 D.gini instquality td1970-td2015, cl(id)
* Column 4: Baseline controls and lagged controls
qui eststo tablea7c4: reg D.lgdppw L.lgdppw D.lkpw L.lkpw D.asr1560 L.asr1560 D.syos1564 L.syos1564 instquality td1970-td2015, cl(id)
* Column 5: Baseline controls and country-specific growth trends
mi extract 0
qui eststo tablea7c5: xtreg D.lgdppw L.lgdppw D.lkpw D.asr1560 D.syos1564 L.syos1564 instquality td1970-td2015, fe cl(id)
* Column 6: Panel GMM
qui eststo tablea7c6: xtabond2 D.lgdppw L.lgdppw D.lkpw D.asr1560 D.syos1564 L.syos1564 instquality td1970-td2015, ///
	gmm(L.lgdppw lkpw asr1560 syos1564 L.syos1564, l(1 1)) iv(D.wfpopratio instquality td1970-td2015) cl(id) two
mat m = e(diffsargan)
loc diffhp: di %5.2f m[5,1]
estadd sca diffhp = `diffhp': tablea7c6
estadd sca N_clust = e(N_g): tablea7c6
* Display results
esttab tablea7*, b(%8.3f) se(%8.3f) star(* .1 ** .05 *** .01) k(L.lgdppw D.lkpw D.asr1560 D.syos1564) sca(N_clust N r2 ar2p hansenp diffhp) ///
	sfmt(%4.0f %4.0f %4.2f %4.2f %4.2f %4.2f) dep noobs nonotes compress

********************************************************************************
* Table A.8: Robustness: Life Expectancy

use "bckps_data.dta", clear
mi xtset id year, delta(5)
* Column 1: Baseline controls
qui eststo tablea8c1: reg D.lgdppc L.lgdppc D.lkpw D.lexpb D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, cl(id)
* Column 2: Baseline controls and working experience
qui eststo tablea8c2: reg D.lgdppc L.lgdppc D.lkpw D.lexpb D.syos1564 L.syos1564 D.exp D.expsq D.wfpopratio instquality td1970-td2015, cl(id)
* Column 3: Baseline controls and income inequality
qui eststo tablea8c3: mi est, post: reg D.lgdppc L.lgdppc D.lkpw D.lexpb D.syos1564 L.syos1564 D.gini D.wfpopratio instquality td1970-td2015, cl(id)
* Column 4: Baseline controls and lagged controls
qui eststo tablea8c4: reg D.lgdppc L.lgdppc D.lkpw L.lkpw D.lexpb L.lexpb D.syos1564 L.syos1564 D.wfpopratio L.wfpopratio instquality td1970-td2015, cl(id)
* Column 5: Baseline controls and country-specific growth trends
mi extract 0
qui eststo tablea8c5: xtreg D.lgdppc L.lgdppc D.lkpw D.lexpb D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, fe cl(id)
* Column 6: Panel GMM
qui eststo tablea8c6: xtabond2 D.lgdppc L.lgdppc D.lkpw D.lexpb D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, ///
	gmm(L.lgdppc lkpw lexpb syos1564 L.syos1564, l(1 1)) iv(D.wfpopratio instquality td1970-td2015) cl(id) two
mat m = e(diffsargan)
loc diffhp: di %5.2f m[5,1]
estadd sca diffhp = `diffhp': tablea8c6
estadd sca N_clust = e(N_g): tablea8c6
* Display results
esttab tablea8*, b(%8.3f) se(%8.3f) star(* .1 ** .05 *** .01) k(L.lgdppc D.lkpw D.lexpb D.syos1564 D.wfpopratio) sca(N_clust N r2 ar2p hansenp diffhp) ///
	sfmt(%4.0f %4.0f %4.2f %4.2f %4.2f %4.2f) dep noobs nonotes compress

********************************************************************************
* Table A.9: Robustness: Years of Schooling

use "bckps_data.dta", clear
mi xtset id year, delta(5)
* Column 1: Baseline controls
qui eststo tablea9c1: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.yos1564 L.yos1564 D.wfpopratio instquality td1970-td2015, cl(id)
* Column 2: Baseline controls and working experience
qui eststo tablea9c2: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.yos1564 L.yos1564 D.exp D.expsq D.wfpopratio instquality td1970-td2015, cl(id)
* Column 3: Baseline controls and income inequality
qui eststo tablea9c3: mi est, post: reg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.yos1564 L.yos1564 D.gini D.wfpopratio instquality td1970-td2015, cl(id)
* Column 4: Baseline controls and lagged controls
qui eststo tablea9c4: reg D.lgdppc L.lgdppc D.lkpw L.lkpw D.asr1560 L.asr1560 D.yos1564 L.yos1564 D.wfpopratio L.wfpopratio instquality td1970-td2015, cl(id)
* Column 5: Baseline controls and country-specific growth trends
mi extract 0
qui eststo tablea9c5: xtreg D.lgdppc L.lgdppc D.lkpw D.asr1560 D.yos1564 L.yos1564 D.wfpopratio instquality td1970-td2015, fe cl(id)
* Column 6: Panel GMM
qui eststo tablea9c6: xtabond2 D.lgdppc L.lgdppc D.lkpw D.asr1560 D.yos1564 L.yos1564 D.wfpopratio instquality td1970-td2015, ///
	gmm(L.lgdppc lkpw asr1560 yos1564 L.yos1564, l(1 1)) iv(D.wfpopratio instquality td1970-td2015) cl(id) two
mat m = e(diffsargan)
loc diffhp: di %5.2f m[5,1]
estadd sca diffhp = `diffhp': tablea9c6
estadd sca N_clust = e(N_g): tablea9c6
* Display results
esttab tablea9*, b(%8.3f) se(%8.3f) star(* .1 ** .05 *** .01) k(L.lgdppc D.lkpw D.asr1560 D.yos1564 D.wfpopratio) sca(N_clust N r2 ar2p hansenp diffhp) sfmt(a2) dep noobs nonotes compress

********************************************************************************
* Table A.10: Robustness: Alternative GMM specifications

use "bckps_data.dta", clear
mi xtset id year, delta(5)
mi extract 0
* Column 1: Baseline GMM
qui eststo tablea10c1: xtabond2 D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, ///
	gmm(L.lgdppc lkpw asr1560 syos1564 L.syos1564, l(1 1)) iv(D.wfpopratio instquality td1970-td2015) cl(id) two
mat m = e(diffsargan)
loc diffhp: di %5.2f m[5,1]
estadd sca diffhp = `diffhp': tablea10c1
* Column 2: Forward orthogonal deviations
qui eststo tablea10c2: xtabond2 D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, ///
	gmm(L.lgdppc lkpw asr1560 syos1564 L.syos1564, l(1 1)) iv(D.wfpopratio instquality td1970-td2015) cl(id) two or
mat m = e(diffsargan)
loc diffhp: di %5.2f m[5,1]
estadd sca diffhp = `diffhp': tablea10c2
* Column 3: Instrument with second lag
qui eststo tablea10c3: xtabond2 D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, ///
	gmm(L.lgdppc lkpw asr1560 syos1564 L.syos1564, l(2 2)) iv(D.wfpopratio instquality td1970-td2015) cl(id) two
mat m = e(diffsargan)
loc diffhp: di %5.2f m[5,1]
estadd sca diffhp = `diffhp': tablea10c3
* Column 4: Instrument set collapsed
qui eststo tablea10c4: xtabond2 D.lgdppc L.lgdppc D.lkpw D.asr1560 D.syos1564 L.syos1564 D.wfpopratio instquality td1970-td2015, ///
	gmm(L.lgdppc lkpw asr1560 syos1564 L.syos1564, c) iv(D.wfpopratio instquality td1970-td2015) cl(id) two
mat m = e(diffsargan)
loc diffhp: di %5.2f m[5,1]
estadd sca diffhp = `diffhp': tablea10c4
* Display results
esttab tablea10*, b(%8.3f) se(%8.3f) star(* .1 ** .05 *** .01) k(L.lgdppc D.lkpw D.asr1560 D.syos1564 D.wfpopratio) sca(N_g N j ar2p hansenp diffhp) ///
	sfmt(%4.0f %4.0f %4.0f %4.2f %4.2f %4.2f) dep noobs nonotes compress

clear all
exit

********************************************************************************
********************************************************************************